package activitys;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;

import com.boboqi.test.R;

import java.util.ArrayList;
import java.util.List;

import adapters.MyListAdapter;
import adapters.MyViewPagerAdapter;

/**
 * Created by pc on 2017/2/20.
 */
public class ParentViewActivity extends AppCompatActivity {

    private ListView lv;
    private ViewPager vp;

    private MyListAdapter adapter = null;
    private MyViewPagerAdapter viewPagerAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_parent_view);
        initView();
        initListData();
        initViewPagerData();
    }

    public void initView() {
        lv = (ListView) findViewById(R.id.lv);
        vp = (ViewPager) findViewById(R.id.vp);
    }

    public void initListData() {
        adapter = new MyListAdapter(this);
        lv.setAdapter(adapter);
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            list.add(i + "");
        }
        adapter.setData(list);
    }

    public void initViewPagerData() {
        viewPagerAdapter = new MyViewPagerAdapter(getSupportFragmentManager());
        vp.setAdapter(viewPagerAdapter);
    }
}
